
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title></title>
    <link rel="stylesheet" type="text/css" href="../../lib/ext/resources/css/ext-all-neptune.css"/>
    <script type="text/javascript" src="../../lib/ext/ext-all.js"></script>
    <script type="text/javascript" src="../../lib/myext_common.js"></script>
</head>
<script type="text/javascript">
    Ext.Loader.setConfig({enabled: true});
    var dataForm;
    var data = {};
    Ext.onReady(function () {
        function doAdd(){
            var params = dataForm.form.getValues();
            var _url = '/dict/add';
            if(params && params.dict_id ){
                _url = '/dict/edit';
            }
            Ext.Ajax.request({
                url: _url,
                params : params,
                method : 'POST',
                success: handlerJsonResponse
            });

        }
        function doClose(){
            parent.closeWin();
        }
        var tbar = [
            {pressed: true,text: '保  存',handler: doAdd,icon : '../../img/add.png'},
            {pressed: true,text: "关  闭",handler: doClose,icon : '../../img/close.png'}
        ];
        dataForm = new Ext.FormPanel({
            layout : 'fit',
            items: [
                {
                    xtype: 'form',
                    defaultType: 'textfield',
                    items: [
                        {
                            name : 'dict_id',
                            hidden : true
                        },
                        {
                            fieldLabel: '字典catgory',
                            name : 'dict_cat',
                            labelAlign:'right',
                            allowBlank: true
                        },
                        {
                            fieldLabel: '字典名',
                            name : 'dict_key',
                            labelAlign:'right',
                            allowBlank: false
                        },
                        {
                            fieldLabel: '字典值',
                            name : 'dict_value',
                            labelAlign:'right',
                            allowBlank: false
                        },{
                            fieldLabel: '备注',
                            name : 'dict_remark',
                            labelAlign:'right'
                        }
                    ],
                    tbar : tbar
                }
            ]
        });
        var viewport = new Ext.Viewport({
            layout: 'fit',
            renderTo: document.body,
            items: [dataForm]
        });
        var _urlparams = Ext.urlDecode(document.URL.split("?")[document.URL.split("?").length - 1]);
        if(_urlparams && _urlparams.dict_id){
            Ext.Ajax.request({
                url: '/dict/list_byid',
                params : {'dict_id' : _urlparams.dict_id},
                method : 'get',
                success: handlerJsonResponseAndInitForm
            });
        }
    });
</script>
<body>
</body>
</html>